package com.myapi.client;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.jdo.annotations.Extension;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;



@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class TablePotInfo implements Serializable{
	@PrimaryKey      
	   @Extension(vendorName="datanucleus", key="gae.encoded-pk", value="true")
	   @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
		     private String phId; 

	@Persistent
	  private ArrayList<PotContributionInfo> contributions;
	@Persistent
	    private boolean closed;
	@Persistent
	    private boolean playerAllIn;
	    
	public TablePotInfo() {
		contributions=new ArrayList<PotContributionInfo>();
	}

	  
     public double getAllPlayerContributions(PlayerInfo player) {
         List<PotContributionInfo> potConts = getContributions();
         double playerConts = 0.0;
         for(int i = 0; i < potConts.size(); i++) {
             PotContributionInfo potC = potConts.get(i);
             if(potC.getPlayer().equals(player))
            	 playerConts=+potC.getAmount();          
         }        
         return playerConts;
     }
     
      
     
	public ArrayList<PotContributionInfo> getContributions() {
		return contributions;
	}

	public void setContributions(ArrayList<PotContributionInfo> contributions) {
		this.contributions = contributions;
	}

	public boolean isClosed() {
		return closed;
	}

	public void setClosed(boolean closed) {
		this.closed = closed;
	}

	public boolean isPlayerAllIn() {
		return playerAllIn;
	}

	public void setPlayerAllIn(boolean playerAllIn) {
		this.playerAllIn = playerAllIn;
	}

}
